package com.scau.service;

import java.util.ArrayList;
import java.util.List;
import com.hibernate.model.TeacherDAO;
import com.hibernate.model.Teacher;
import com.scau.bean.PageBean;
public class TeacherService {
	private Teacher teacher;
	private TeacherDAO teacherDao;
	
	/**
	 * @return the teacherDao
	 */
	public TeacherDAO getTeacherDao() {
		return teacherDao;
	}

	/**
	 * @param teacherDao the teacherDao to set
	 */
	public void setTeacherDao(TeacherDAO teacherDao) {
		this.teacherDao = teacherDao;
	}

	public List<Teacher> listAll(){
		return teacherDao.findAll();
	}
	
	public void save(Teacher teacher){
		teacherDao.save(teacher);
	}
	
	public List<Teacher> listAllByPage(PageBean pageBean){
		return teacherDao.listTeacherByPage(pageBean);
	}
	
	public Teacher findbyAccount(String tname){
		ArrayList<Teacher> list = (ArrayList<Teacher>) teacherDao.findByTname(tname);
		if (list == null || list.size() == 0){  return null;}
		else   
		     return list.get(0);
			}
}
